home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / vibrant / vibprmpt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-05  |  18.4 KB  |  759 lines  |  [TEXT/R*ch]

  1. /*   vibprmpt.c
  2. * ===========================================================================
  3. *
  4. *                            PUBLIC DOMAIN NOTICE
  5. *            National Center for Biotechnology Information (NCBI)
  6. *
  7. *  This software/database is a "United States Government Work" under the
  8. *  terms of the United States Copyright Act.  It was written as part of
  9. *  the author's official duties as a United States Government employee and
  10. *  thus cannot be copyrighted.  This software/database is freely available
  11. *  to the public for use. The National Library of Medicine and the U.S.
  12. *  Government do not place any restriction on its use or reproduction.
  13. *  We would, however, appreciate having the NCBI and the author cited in
  14. *  any work or product based on this material
  15. *
  16. *  Although all reasonable efforts have been taken to ensure the accuracy
  17. *  and reliability of the software and data, the NLM and the U.S.
  18. *  Government do not and cannot warrant the performance or results that
  19. *  may be obtained by using this software or data. The NLM and the U.S.
  20. *  Government disclaim all warranties, express or implied, including
  21. *  warranties of performance, merchantability or fitness for any particular
  22. *  purpose.
  23. *
  24. * ===========================================================================
  25. *
  26. * File Name:  vibprmpt.c
  27. *
  28. * Author:  Jonathan Kans
  29. *
  30. * Version Creation Date:   7/1/91
  31. *
  32. * $Revision: 2.7 $
  33. *
  34. * File Description: 
  35. *       Vibrant prompt functions
  36. *
  37. * Modifications:  
  38. * --------------------------------------------------------------------------
  39. * Date     Name        Description of modification
  40. * -------  ----------  -----------------------------------------------------
  41. *
  42. *
  43. * ==========================================================================
  44. */
  45.  
  46. #include <vibtypes.h>
  47. #include <vibprocs.h>
  48. #include <vibincld.h>
  49.  
  50. #ifdef WIN_MAC
  51. #define Nlm_PromptTool Nlm_Handle
  52. #endif
  53.  
  54. #ifdef WIN_MSWIN
  55. #define Nlm_PromptTool HWND
  56. #endif
  57.  
  58. #ifdef WIN_MOTIF
  59. #define Nlm_PromptTool Widget
  60. #endif
  61.  
  62. typedef  struct  Nlm_promptdata {
  63.   Nlm_PromptTool  handle;
  64.   Nlm_FonT        font;
  65.   Nlm_Int2        height;
  66.   Nlm_Char        just;
  67. } Nlm_PromptData;
  68.  
  69. typedef  struct  Nlm_promptrec {
  70.   Nlm_GraphicRec  graphicR;
  71.   Nlm_PromptData  prompt;
  72. } Nlm_PromptRec, PNTR Nlm_PptPtr;
  73.  
  74. static Nlm_GphPrcsPtr  gphprcsptr = NULL;
  75.  
  76. static Nlm_GphPrcsPtr  promptProcs;
  77. static Nlm_GphPrcsPtr  staticPromptProcs;
  78.  
  79. static Nlm_PrompT      recentPrompt = NULL;
  80. static Nlm_PromptData  recentPromptData;
  81.  
  82. static void Nlm_LoadPromptData (Nlm_PrompT p, Nlm_PromptTool hdl,
  83.                                 Nlm_FonT fnt, Nlm_Int2 hgt,
  84.                                 Nlm_Char jst)
  85.  
  86. {
  87.   Nlm_PptPtr      pp;
  88.   Nlm_PromptData  PNTR pptr;
  89.  
  90.   if (p != NULL) {
  91.     pp = (Nlm_PptPtr) Nlm_HandLock (p);
  92.     pptr = &(pp->prompt);
  93.     pptr->handle = hdl;
  94.     pptr->font = fnt;
  95.     pptr->height = hgt;
  96.     pptr->just = jst;
  97.     Nlm_HandUnlock (p);
  98.     recentPrompt = NULL;
  99.   }
  100. }
  101.  
  102. static void Nlm_SetPromptData (Nlm_PrompT p, Nlm_PromptData * pdata)
  103.  
  104. {
  105.   Nlm_PptPtr  pp;
  106.  
  107.   if (p != NULL && pdata != NULL) {
  108.     pp = (Nlm_PptPtr) Nlm_HandLock (p);
  109.     pp->prompt = *pdata;
  110.     Nlm_HandUnlock (p);
  111.     recentPrompt = p;
  112.     recentPromptData = *pdata;
  113.   }
  114. }
  115.  
  116. static void Nlm_GetPromptData (Nlm_PrompT p, Nlm_PromptData * pdata)
  117.  
  118. {
  119.   Nlm_PptPtr  pp;
  120.  
  121.   if (p != NULL && pdata != NULL) {
  122.     if (p == recentPrompt && NLM_RISKY) {
  123.       *pdata = recentPromptData;
  124.     } else {
  125.       pp = (Nlm_PptPtr) Nlm_HandLock (p);
  126.       *pdata = pp->prompt;
  127.       Nlm_HandUnlock (p);
  128.       recentPrompt = p;
  129.       recentPromptData = *pdata;
  130.     }
  131.   }
  132. }
  133.  
  134. static void Nlm_SetPromptHandle (Nlm_PrompT p, Nlm_PromptTool hdl)
  135.  
  136. {
  137.   Nlm_PromptData  pdata;
  138.  
  139.   Nlm_GetPromptData (p, &pdata);
  140.   pdata.handle = hdl;
  141.   Nlm_SetPromptData (p, &pdata);
  142. }
  143.  
  144. static Nlm_PromptTool Nlm_GetPromptHandle (Nlm_PrompT p)
  145.  
  146. {
  147.   Nlm_PromptData  pdata;
  148.  
  149.   Nlm_GetPromptData (p, &pdata);
  150.   return pdata.handle;
  151. }
  152.  
  153. #ifdef WIN_MAC
  154. static void Nlm_DrawPrompt (Nlm_GraphiC p)
  155.  
  156. {
  157.   Nlm_Boolean     gray;
  158.   Nlm_PromptTool  h;
  159.   Nlm_PromptData  pd;
  160.   Nlm_RecT        r;
  161.   Nlm_Char        str [256];
  162.  
  163.   if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
  164.     Nlm_GetPromptData ((Nlm_PrompT) p, &pd);
  165.     h = pd.handle;
  166.     if (h != NULL) {
  167.       if (pd.font != NULL) {
  168.         Nlm_SelectFont (pd.font);
  169.       }
  170.       Nlm_GetString (h, str, sizeof (str));
  171.       if (Nlm_StringLen (str) > 0) {
  172.         if (Nlm_Enabled (p)) {
  173.           gray = FALSE;
  174.         } else {
  175.           gray = TRUE;
  176.         }
  177.         Nlm_GetRect (p, &r);
  178.         Nlm_DrawString (&r, str, pd.just, gray);
  179.       }
  180.       Nlm_SelectFont (Nlm_systemFont);
  181.     }
  182.   }
  183. }
  184. #endif
  185.  
  186. static void Nlm_ShowPrompt (Nlm_GraphiC p, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  187.  
  188. {
  189.   Nlm_PromptTool  h;
  190.   Nlm_WindoW      tempPort;
  191.  
  192.   if (setFlag) {
  193.     Nlm_SetVisible (p, TRUE);
  194.   }
  195.   if (Nlm_GetVisible (p) && Nlm_AllParentsButWindowVisible (p)) {
  196.     tempPort = Nlm_SavePortIfNeeded (p, savePort);
  197.     h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
  198. #ifdef WIN_MAC
  199.     Nlm_DoDraw (p);
  200. #endif
  201. #ifdef WIN_MSWIN
  202.     ShowWindow (h, SW_SHOW);
  203.     UpdateWindow (h);
  204. #endif
  205. #ifdef WIN_MOTIF
  206.     XtManageChild (h);
  207. #endif
  208.     Nlm_RestorePort (tempPort);
  209.   }
  210. }
  211.  
  212. static void Nlm_HidePrompt (Nlm_GraphiC p, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  213.  
  214. {
  215.   Nlm_PromptTool  h;
  216.   Nlm_WindoW      tempPort;
  217. #ifdef WIN_MAC
  218.   Nlm_RecT        r;
  219. #endif
  220.  
  221.   if (setFlag) {
  222.     Nlm_SetVisible (p, FALSE);
  223.   }
  224.   tempPort = Nlm_SavePortIfNeeded (p, savePort);
  225.   h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
  226. #ifdef WIN_MAC
  227.   if (Nlm_GetAllParentsVisible (p)) {
  228.     Nlm_GetRect (p, &r);
  229.     Nlm_InsetRect (&r, -1, -1);
  230.     Nlm_EraseRect (&r);
  231.     Nlm_ValidRect (&r);
  232.   }
  233. #endif
  234. #ifdef WIN_MSWIN
  235.   ShowWindow (h, SW_HIDE);
  236.   UpdateWindow (h);
  237. #endif
  238. #ifdef WIN_MOTIF
  239.   XtUnmanageChild (h);
  240. #endif
  241.   Nlm_RestorePort (tempPort);
  242. }
  243.  
  244. static void Nlm_EnablePrompt (Nlm_GraphiC p, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  245.  
  246. {
  247.   Nlm_PromptTool  h;
  248.   Nlm_WindoW      tempPort;
  249. #ifdef WIN_MAC
  250.   Nlm_RecT        r;
  251. #endif
  252.  
  253.   if (setFlag) {
  254.     Nlm_SetEnabled (p, TRUE);
  255.   }
  256.   if (Nlm_GetEnabled (p) && Nlm_GetAllParentsEnabled (p)) {
  257.     tempPort = Nlm_SavePortIfNeeded (p, savePort);
  258.     h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
  259. #ifdef WIN_MAC
  260.     if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
  261.       if (h != NULL) {
  262.         Nlm_DrawPrompt (p);
  263.       } else {
  264.         Nlm_GetRect (p, &r);
  265.         Nlm_InvalRect (&r);
  266.       }
  267.     }
  268. #endif
  269. #ifdef WIN_MSWIN
  270.     EnableWindow (h, TRUE);
  271. #endif
  272. #ifdef WIN_MOTIF
  273.     XtVaSetValues (h, XmNsensitive, TRUE, NULL);
  274. #endif
  275.     Nlm_RestorePort (tempPort);
  276.   }
  277. }
  278.  
  279. static void Nlm_DisablePrompt (Nlm_GraphiC p, Nlm_Boolean setFlag, Nlm_Boolean savePort)
  280.  
  281. {
  282.   Nlm_PromptTool  h;
  283.   Nlm_WindoW      tempPort;
  284. #ifdef WIN_MAC
  285.   Nlm_RecT        r;
  286. #endif
  287.  
  288.   if (setFlag) {
  289.     Nlm_SetEnabled (p, FALSE);
  290.   }
  291.   tempPort = Nlm_SavePortIfNeeded (p, savePort);
  292.   h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
  293. #ifdef WIN_MAC
  294.   if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
  295.     if (h != NULL) {
  296.       Nlm_DrawPrompt (p);
  297.     } else {
  298.       Nlm_GetRect (p, &r);
  299.       Nlm_InvalRect (&r);
  300.     }
  301.   }
  302. #endif
  303. #ifdef WIN_MSWIN
  304.   EnableWindow (h, FALSE);
  305. #endif
  306. #ifdef WIN_MOTIF
  307.   XtVaSetValues (h, XmNsensitive, FALSE, NULL);
  308. #endif
  309.   Nlm_RestorePort (tempPort);
  310. }
  311.  
  312. static void Nlm_RemovePrompt (Nlm_GraphiC p, Nlm_Boolean savePort)
  313.  
  314. {
  315.   Nlm_PromptTool  h;
  316.   Nlm_WindoW      tempPort;
  317.  
  318.   tempPort = Nlm_SavePortIfNeeded (p, savePort);
  319.   h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
  320.   if (h != NULL) {
  321. #ifdef WIN_MAC
  322.     Nlm_HandFree (h);
  323. #endif
  324. #ifdef WIN_MSWIN
  325.     DestroyWindow (h);
  326. #endif
  327. #ifdef WIN_MOTIF
  328.     XtDestroyWidget (h);
  329. #endif
  330.   }
  331.   Nlm_HandFree (p);
  332.   recentPrompt = NULL;
  333.   Nlm_RestorePort (tempPort);
  334. }
  335.  
  336. static void Nlm_RemoveLinkedInPrompt (Nlm_GraphiC p, Nlm_Boolean savePort)
  337.  
  338. {
  339.   Nlm_PromptTool  h;
  340.   Nlm_WindoW      tempPort;
  341.  
  342.   tempPort = Nlm_SavePortIfNeeded (p, savePort);
  343.   h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
  344.   if (h != NULL) {
  345. #ifdef WIN_MAC
  346.     Nlm_HandFree (h);
  347. #endif
  348. #ifdef WIN_MSWIN
  349.     DestroyWindow (h);
  350. #endif
  351. #ifdef WIN_MOTIF
  352.     XtDestroyWidget (h);
  353. #endif
  354.   }
  355.   Nlm_RemoveLink (p);
  356.   recentPrompt = NULL;
  357.   Nlm_RestorePort (tempPort);
  358. }
  359.  
  360. static void Nlm_SetPromptTitle (Nlm_GraphiC p, Nlm_Int2 item,
  361.                                 Nlm_CharPtr title, Nlm_Boolean savePort)
  362.  
  363. {
  364.   Nlm_PromptTool  h;
  365.   Nlm_WindoW      tempPort;
  366. #ifdef WIN_MAC
  367.   Nlm_RecT        r;
  368. #endif
  369. #ifdef WIN_MOTIF
  370.   XmString        label;
  371. #endif
  372.  
  373.   tempPort = Nlm_SavePortIfNeeded (p, savePort);
  374.   h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
  375. #ifdef WIN_MAC
  376.   h = Nlm_SetString (h, title);
  377.   Nlm_SetPromptHandle ((Nlm_PrompT) p, h);
  378.   if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
  379.     if (h != NULL) {
  380.       Nlm_DrawPrompt (p);
  381.     } else {
  382.       Nlm_GetRect (p, &r);
  383.       Nlm_InvalRect (&r);
  384.     }
  385.   }
  386. #endif
  387. #ifdef WIN_MSWIN
  388.   if (h != NULL) {
  389.     SetWindowText (h, title);
  390.     if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
  391.       UpdateWindow (h);
  392.     }
  393.   }
  394. #endif
  395. #ifdef WIN_MOTIF
  396.   if (h != NULL) {
  397.     label = XmStringCreateSimple (title);
  398.     XtVaSetValues (h, XmNlabelString, label, NULL);
  399.     XmStringFree (label);
  400.   }
  401. #endif
  402.   Nlm_RestorePort (tempPort);
  403. }
  404.  
  405. static void Nlm_GetPromptTitle (Nlm_GraphiC p, Nlm_Int2 item,
  406.                                 Nlm_CharPtr title, Nlm_sizeT maxsize)
  407.  
  408. {
  409.   Nlm_PromptTool  h;
  410.   Nlm_Char        temp [256];
  411. #ifdef WIN_MOTIF
  412.   XmString        label;
  413.   char            *text;
  414. #endif
  415.  
  416.   if (title != NULL) {
  417.     h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
  418.     if (h != NULL) {
  419. #ifdef WIN_MAC
  420.       Nlm_GetString (h, title, maxsize);
  421. #endif
  422. #ifdef WIN_MSWIN
  423.       GetWindowText (h, temp, sizeof (temp));
  424.       Nlm_StringNCpy (title, temp, maxsize);
  425. #endif
  426. #ifdef WIN_MOTIF
  427.       XtVaGetValues (h, XmNlabelString, &label, NULL);
  428.       title [0] = '\0';
  429.       if (XmStringGetLtoR (label, XmSTRING_DEFAULT_CHARSET, &text)) {
  430.         Nlm_StringNCpy (title, text, maxsize);
  431.         XtFree (text);
  432.       }
  433. #endif
  434.     } else {
  435.       Nlm_StringNCpy (title, "", maxsize);
  436.     }
  437.   }
  438. }
  439.  
  440. static void Nlm_InvalPrompt (Nlm_GraphiC p)
  441.  
  442. {
  443.   Nlm_RecT        r;
  444.   Nlm_RectTool    rtool;
  445.   Nlm_WindowTool  wptr;
  446.  
  447.   if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
  448. #ifdef WIN_MAC
  449.     Nlm_GetRect (p, &r);
  450.     Nlm_InsetRect (&r, -1, -1);
  451.     Nlm_InvalRect (&r);
  452. #endif
  453. #ifdef WIN_MSWIN
  454.     wptr = Nlm_ParentWindowPtr (p);
  455.     Nlm_GetRect (p, &r);
  456.     r.top = r.bottom - 1;
  457.     r.bottom++;
  458.     Nlm_RecTToRectTool (&r, &rtool);
  459.     InvalidateRect (wptr, &rtool, TRUE);
  460.     Nlm_GetRect (p, &r);
  461.     r.left = r.right - 1;
  462.     r.right++;
  463.     Nlm_RecTToRectTool (&r, &rtool);
  464.     InvalidateRect (wptr, &rtool, TRUE);
  465. #endif
  466. #ifdef WIN_MOTIF
  467. #endif
  468.   }
  469. }
  470.  
  471. static void Nlm_SetPromptPosition (Nlm_GraphiC p, Nlm_RectPtr r, Nlm_Boolean savePort)
  472.  
  473. {
  474.   Nlm_Int2        delta;
  475.   Nlm_PromptTool  h;
  476.   Nlm_Int2        height;
  477.   Nlm_Int2        limit;
  478.   Nlm_RecT        oldRect;
  479.   Nlm_PromptData  pdata;
  480.   Nlm_RecT        rct;
  481.   Nlm_WindoW      tempPort;
  482.  
  483.   if (r != NULL) {
  484.     Nlm_DoGetPosition (p, &oldRect);
  485.     if (! Nlm_EqualRect (r, &oldRect)) {
  486.       tempPort = Nlm_SavePortIfNeeded (p, savePort);
  487.       Nlm_GetPromptData ((Nlm_PrompT) p, &pdata);
  488.       h = pdata.handle;
  489.       rct = *r;
  490.       limit = ABS (rct.bottom - rct.top);
  491.       height = pdata.height;
  492.       delta = limit - height;
  493.       if (delta > 0) {
  494.         rct.top += delta / 2;
  495.         rct.bottom = rct.top + height;
  496.       }
  497. #ifdef WIN_MAC
  498.       Nlm_InvalPrompt (p);
  499.       Nlm_SetRect (p, r);
  500.       Nlm_InvalPrompt (p);
  501. #endif
  502. #ifdef WIN_MSWIN
  503.       Nlm_SetRect (p, r);
  504.       if (h != NULL) {
  505.         MoveWindow (h, rct.left, rct.top, rct.right - rct.left,
  506.                     rct.bottom - rct.top, TRUE);
  507.         UpdateWindow (h);
  508.       }
  509. #endif
  510. #ifdef WIN_MOTIF
  511.       XtVaSetValues (h,
  512.                      XmNx, (Position) rct.left,
  513.                      XmNy, (Position) rct.top,
  514.                      XmNwidth, (Dimension) (rct.right - rct.left),
  515.                      XmNheight, (Dimension) (rct.bottom - rct.top), 
  516.                      NULL);
  517.       Nlm_SetRect (p, r);
  518. #endif
  519.       Nlm_RestorePort (tempPort);
  520.     }
  521.   }
  522. }
  523.  
  524. static void Nlm_GetPromptPosition (Nlm_GraphiC p, Nlm_RectPtr r)
  525.  
  526. {
  527.   if (r != NULL) {
  528.     Nlm_GetRect (p, r);
  529.   }
  530. }
  531.  
  532. static void Nlm_NewPrompt (Nlm_PrompT p, Nlm_CharPtr title, Nlm_FonT font, Nlm_Char just)
  533.  
  534. {
  535.   Nlm_Int2        delta;
  536.   Nlm_PromptTool  h;
  537.   Nlm_Int2        height;
  538.   Nlm_Int2        limit;
  539.   Nlm_Char        local [128];
  540.   Nlm_RecT        r;
  541.   Nlm_Int4        style;
  542.   Nlm_WindowTool  wptr;
  543. #ifdef WIN_MSWIN
  544.   Nlm_FntPtr      fntptr;
  545. #endif
  546. #ifdef WIN_MOTIF
  547.   Nlm_FntPtr      fntptr;
  548.   XmFontList      fontlist;
  549.   XmString        label;
  550.   Cardinal        n;
  551.   Arg             wargs [15];
  552. #endif
  553.  
  554.   local [0] = '\0';
  555.   Nlm_StringNCpy (local, title, sizeof (local) - 1);
  556.   Nlm_GetRect ((Nlm_GraphiC) p, &r);
  557.   limit = ABS (r.bottom - r.top);
  558.   height = Nlm_LineHeight ();
  559.   delta = limit - height;
  560.   if (delta > 0) {
  561.     r.top += delta / 2;
  562.     r.bottom = r.top + height;
  563.   }
  564.   wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) p);
  565. #ifdef WIN_MAC
  566.   h = Nlm_SetString (NULL, local);
  567. #endif
  568. #ifdef WIN_MSWIN
  569.   switch (just) {
  570.     case 'r':
  571.       style = SS_RIGHT;
  572.       break;
  573.     case 'l':
  574.       style = SS_LEFT;
  575.       break;
  576.     case 'c':
  577.       style = SS_CENTER;
  578.       break;
  579.     default:
  580.       style = SS_LEFT;
  581.       break;
  582.   }
  583.   h = CreateWindow ("Static", local, WS_CHILD | style,
  584.                     r.left, r.top, r.right - r.left,
  585.                     r.bottom - r.top, wptr, 0,
  586.                     Nlm_currentHInst, NULL);
  587.   if (font != NULL) {
  588.     fntptr = (Nlm_FntPtr) Nlm_HandLock (font);
  589.     if (fntptr != NULL && fntptr->handle != NULL) {
  590.       SetWindowFont (h, fntptr->handle, FALSE);
  591.     }
  592.     Nlm_HandUnlock (font);
  593.   }
  594. #endif
  595. #ifdef WIN_MOTIF
  596.   fontlist = NULL;
  597.   if (font != NULL) {
  598.     fntptr = (Nlm_FntPtr) Nlm_HandLock (font);
  599.     if (fntptr != NULL && fntptr->handle != NULL) {
  600.       fontlist = XmFontListCreate (fntptr->handle, XmSTRING_DEFAULT_CHARSET);
  601.     }
  602.     Nlm_HandUnlock (font);
  603.   }
  604.   if (local [0] == '\0') {
  605.     local [0] = ' ';
  606.     local [1] = '\0';
  607.   }
  608.   label = XmStringCreateSimple (local);
  609.   n = 0;
  610.   XtSetArg (wargs [n], XmNlabelString, label); n++;
  611.   XtSetArg (wargs [n], XmNx, (Position) r.left); n++;
  612.   XtSetArg (wargs [n], XmNy, (Position) r.top); n++;
  613.   XtSetArg (wargs [n], XmNwidth, (Dimension) (r.right - r.left)); n++;
  614.   XtSetArg (wargs [n], XmNheight, (Dimension) (r.bottom - r.top)); n++;
  615.   XtSetArg (wargs [n], XmNmarginHeight, 0); n++;
  616.   XtSetArg (wargs [n], XmNmarginWidth, 0); n++;
  617.   XtSetArg (wargs [n], XmNborderWidth, (Dimension) 0); n++;
  618.   XtSetArg (wargs [n], XmNrecomputeSize, FALSE); n++;
  619.   XtSetArg (wargs [n], XmNfontList, fontlist); n++;
  620.   switch (just) {
  621.     case 'r':
  622.       XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_END); n++;
  623.       break;
  624.     case 'l':
  625.       XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  626.       break;
  627.     case 'c':
  628.       XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_CENTER); n++;
  629.       break;
  630.     default:
  631.       XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  632.       break;
  633.   }
  634.   h = XmCreateLabel (wptr, (String) "", wargs, n);
  635.   XmStringFree (label);
  636.   if (NLM_QUIET) {
  637.     if (Nlm_WindowHasBeenShown (Nlm_ParentWindow (p))) {
  638.       XtRealizeWidget (h);
  639.     }
  640.   } else {
  641.     XtRealizeWidget (h);
  642.   }
  643.   if (fontlist != NULL) {
  644.     XmFontListFree (fontlist);
  645.   }
  646. #endif
  647.   Nlm_LoadPromptData (p, h, font, height, just);
  648. }
  649.  
  650. extern Nlm_PrompT Nlm_DependentPrompt (Nlm_GraphiC prnt, Nlm_RectPtr r,
  651.                                        Nlm_CharPtr title, Nlm_FonT font,
  652.                                        Nlm_Char just)
  653.  
  654. {
  655.   Nlm_PrompT  p;
  656.   Nlm_WindoW  tempPort;
  657.  
  658.   p = NULL;
  659.   if (prnt != NULL && r != NULL) {
  660.     tempPort = Nlm_SavePort (prnt);
  661.     if (font != NULL) {
  662.       Nlm_SelectFont (font);
  663.     } else {
  664.       Nlm_SelectFont (Nlm_systemFont);
  665.     }
  666.     p = (Nlm_PrompT) Nlm_HandNew (sizeof (Nlm_PromptRec));
  667.     if (p != NULL) {
  668.       Nlm_LoadGraphicData ((Nlm_GraphiC) p, NULL, (Nlm_GraphiC) prnt,
  669.                            NULL, NULL, promptProcs, NULL, r, TRUE, FALSE);
  670.       if (Nlm_nextIdNumber < 32767) {
  671.         Nlm_nextIdNumber++;
  672.       }
  673.       Nlm_NewPrompt (p, title, font, just);
  674.     }
  675.     Nlm_SelectFont (Nlm_systemFont);
  676.     Nlm_RestorePort (tempPort);
  677.   }
  678.   return p;
  679. }
  680.  
  681. extern Nlm_PrompT Nlm_StaticPrompt  (Nlm_GrouP prnt, Nlm_CharPtr title,
  682.                                      Nlm_Int2 pixwidth, Nlm_Int2 pixheight,
  683.                                      Nlm_FonT font, Nlm_Char just)
  684.  
  685. {
  686.   Nlm_PoinT   npt;
  687.   Nlm_PrompT  p;
  688.   Nlm_RecT    r;
  689.   Nlm_WindoW  tempPort;
  690.  
  691.   p = NULL;
  692.   if (prnt != NULL) {
  693.     tempPort = Nlm_SavePort ((Nlm_GraphiC) prnt);
  694.     Nlm_GetNextPosition ((Nlm_GraphiC) prnt, &npt);
  695.     if (font != NULL) {
  696.       Nlm_SelectFont (font);
  697.     } else {
  698.       Nlm_SelectFont (Nlm_systemFont);
  699.     }
  700.     if (pixwidth == 0) {
  701.       pixwidth = Nlm_StringWidth (title) + 2;
  702.     }
  703.     if (pixheight == 0) {
  704.       pixheight = Nlm_LineHeight ();
  705.     }
  706.     Nlm_LoadRect (&r, npt.x, npt.y, npt.x+pixwidth, npt.y+pixheight);
  707.     p = (Nlm_PrompT) Nlm_CreateLink ((Nlm_GraphiC) prnt, &r, sizeof (Nlm_PromptRec),
  708.                                      staticPromptProcs);
  709.     if (p != NULL) {
  710.       Nlm_NewPrompt (p, title, font, just);
  711.       Nlm_DoAdjustPrnt ((Nlm_GraphiC) p, &r, TRUE, FALSE);
  712.       Nlm_DoShow ((Nlm_GraphiC) p, TRUE, FALSE);
  713.     }
  714.     Nlm_SelectFont (Nlm_systemFont);
  715.     Nlm_RestorePort (tempPort);
  716.   }
  717.   return p;
  718. }
  719.  
  720. extern void Nlm_FreePrompt (void)
  721.  
  722. {
  723.   gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemFree (gphprcsptr);
  724. }
  725.  
  726. extern void Nlm_InitPrompt (void)
  727.  
  728. {
  729.   gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemNew (sizeof (Nlm_GphPrcs) * 2);
  730.  
  731.   promptProcs = &(gphprcsptr [0]);
  732. #ifdef WIN_MAC
  733.   promptProcs->draw = Nlm_DrawPrompt;
  734. #endif
  735.   promptProcs->show = Nlm_ShowPrompt;
  736.   promptProcs->hide = Nlm_HidePrompt;
  737.   promptProcs->enable = Nlm_EnablePrompt;
  738.   promptProcs->disable = Nlm_DisablePrompt;
  739.   promptProcs->remove = Nlm_RemovePrompt;
  740.   promptProcs->setTitle = Nlm_SetPromptTitle;
  741.   promptProcs->getTitle = Nlm_GetPromptTitle;
  742.   promptProcs->setPosition = Nlm_SetPromptPosition;
  743.   promptProcs->getPosition = Nlm_GetPromptPosition;
  744.  
  745.   staticPromptProcs = &(gphprcsptr [1]);
  746. #ifdef WIN_MAC
  747.   staticPromptProcs->draw = Nlm_DrawPrompt;
  748. #endif
  749.   staticPromptProcs->show = Nlm_ShowPrompt;
  750.   staticPromptProcs->hide = Nlm_HidePrompt;
  751.   staticPromptProcs->enable = Nlm_EnablePrompt;
  752.   staticPromptProcs->disable = Nlm_DisablePrompt;
  753.   staticPromptProcs->remove = Nlm_RemoveLinkedInPrompt;
  754.   staticPromptProcs->setTitle = Nlm_SetPromptTitle;
  755.   staticPromptProcs->getTitle = Nlm_GetPromptTitle;
  756.   staticPromptProcs->setPosition = Nlm_SetPromptPosition;
  757.   staticPromptProcs->getPosition = Nlm_GetPromptPosition;
  758. }
  759.